package com.kb5173.base.demo.original.hessian;

import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.caucho.hessian.server.HessianSkeleton;

public class MyHttpServlet extends HttpServlet {

	private static ConcurrentHashMap<String, HessianSkeleton> hsMap = new ConcurrentHashMap<String, HessianSkeleton>();
	
	private static final long serialVersionUID = 8506971051235400295L;
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		HessianSkeleton hs = hsMap.get(req.getRequestURI());
		try {
			hs.invoke(req.getInputStream(), resp.getOutputStream());
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
	
	public static void addSkelon(String path, HessianSkeleton hs){
//		hsMap.put(cls.getName(), cls);
		hsMap.put("/"+path, hs);
	}
}
